Skip to content

feat(standards): add fee::assert_fee_bound - #3797

Open
mmagician wants to merge 1 commit into
mmagician-claude/port-fee-estimate-splitfrom
mmagician-claude/port-fee-assert-bound
Open

feat(standards): add fee::assert_fee_bound#3797
mmagician wants to merge 1 commit into
mmagician-claude/port-fee-estimate-splitfrom
mmagician-claude/port-fee-assert-bound

Conversation

@mmagician

@mmagician mmagician commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Ports #3785 to next.

fee::assert_fee_bound lets a caller cap what a transaction may pay before paying it: the payment must be in the native fee asset and at most num / den times the computed fee.

@mmagician
mmagician force-pushed the mmagician-claude/port-fee-assert-bound branch 2 times, most recently from ef30af6 to 65af8a5 Compare September 3, 2026 12:59
@mmagician mmagician changed the title feat(standards): add fee::assert_fee_bound feat(standards): add fee::assert_fee_bound Sep 3, 2026
@mmagician
mmagician force-pushed the mmagician-claude/port-fee-assert-bound branch from 65af8a5 to d0320e2 Compare September 3, 2026 14:03
@mmagician
mmagician requested a review from bobbinth September 3, 2026 14:04
@mmagician
mmagician force-pushed the mmagician-claude/port-fee-assert-bound branch from d0320e2 to 9b4011f Compare September 3, 2026 14:23
Ports #3785 from release/v0.16.0-rc to next.

Adaptations for next:
- pin the payment to the native fee asset by comparing asset IDs via
  `tx::get_fee_asset_id` (`tx::get_fee_faucet_id` no longer exists); the
  error constant is renamed to `ERR_FEE_PAYMENT_ASSET_NOT_NATIVE`
- the bound test helper builds the transaction and the tests own execution

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KkQzFtRjyDwQ7iVtRbsHsn
@mmagician
mmagician force-pushed the mmagician-claude/port-fee-assert-bound branch 2 times, most recently from 9b4011f to 6eb78c3 Compare September 3, 2026 15:06

@bobbinth bobbinth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you!

@zeapoz zeapoz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Comment on lines +305 to +306
# the bound holds iff payment_amount * bound_den <= fee_amount * bound_num; both sides are
# computed as 128-bit products, so the comparison is exact and cannot overflow

@zeapoz zeapoz Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# the bound holds iff payment_amount * bound_den <= fee_amount * bound_num; both sides are
# computed as 128-bit products, so the comparison is exact and cannot overflow
# the bound holds iff payment_amount * bound_den <= fee_amount * bound_num; both sides are
# split into 32-bit limbs and computed as 128-bit products, so the comparison is exact and
# cannot overflow

nit: I think we could explicitly mention the splitting step too to be more precise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants